<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');

class userControl extends Control{
    function index(){
      // C("debug",1);
      $uname=$_SESSION['easyuser'];
      $db=M("user");
      $user=$db->where("username='{$uname}'")->find();  
      $this->assign("user",$user);
      $this->display();
    }

    function change(){
      if (strtolower($_SESSION['code']) != strtolower($_POST['vdcode'])) {
            $this->error("验证码错误", "index");
            die;
      }
      $userid=$_POST['userid'];
      $oldpwd=$_POST['oldpwd'];
      $db=M("user");
      $user=$db->where("userid='{$userid}'")->find();
      // p($user);die;
      if ($oldpwd==$user['password']) {
            if ($db->save()>= 0) {
                $this->success("资料修改成功", "index");
            } else {
                $this->error("资料修改失败，请重试");
            }
            
        } else{
            $this->error("原始密码错误，请重试");
        } 
    }

    
}
?>